package com.march.two.web;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;

import com.march.two.entity.Two;

@Controller
@RequestMapping("/two")
public class TwoContoller {

	//在访问控制器CController时先运行一次
	@ModelAttribute
	public Two init(){
		Two two = new Two();
		two.setName("山驴逼");
		two.setAge("3005");
		two.setSex("banana");
		return two;
	}
	
	//任意一个值都能访问
	@RequestMapping(value={"a","s","d",""})
	public String two(Two twof,HttpServletRequest request,HttpServletResponse response, Model model){
//		Two two = new Two();
//		two.setName("山驴逼");
//		two.setAge("3005");
//		two.setSex("banana");
		//原生的传值方法
		request.setAttribute("msg123", "adsahdsajdkshadjskadhsjadsahdjsakdhsajkdsabcncxzncbajsdb1324564");
		//SpringMVC框架中的传值方法
		model.addAttribute("msg",twof);
		return "two";
	}
}
